<include file="public/layout"/>
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer"
     style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">

    <form class="form-horizontal" id="adminHandle" action="" method="post">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit">
                    <label ><em>*</em>城市选择</label>
                </dt>
                <dd class="opt">
                    <select onchange="get_city(this,0)" id="province" name="province_id">
                        <option>选择省份</option>
                    </select>
                    <select onchange="get_area(this)" id="city" name="city_id">
                        <option>选择城市</option>
                    </select>
                   <select id="district" name="district_id" >
                       <option>选择区域</option>
                   </select>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label >起步价</label>
                </dt>
                <dd class="opt">
                    <input style="width:100px ! important" type="text" name="start_init" class="input-txt" placeholder="起始公里">KM ---
                    <input style="width:100px ! important" type="text" name="val_init" class="input-txt" placeholder="起步价">元
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label >是否开启起步价</label>
                </dt>
                <dd class="opt">
                    <input type="radio" name="is_start" class="input-txt" value="1" checked style="width:20px ! important">是
                    <input type="radio" name="is_start" value="0" class="input-txt" style="width:20px ! important">否
                    <span style="color: red;font-size: 12px;margin-left: 20px">
                        (注意:如果开启起步价，则里程管理的起始公里以起步价的起始公里开始，修改时也请注意里程的衔接，否则会出现价格计算错误)
                    </span>
                </dd>
            </dl>
            <div id="cons">
                <dl class="row">
                    <dt class="tit">
                        <label ><em></em>里程管理</label>
                    </dt>
                    <dd class="opt">
                        <a type="button" class="ncap-btn-big ncap-btn-success" id="adds">添加</a>
                    </dd>
                </dl>
                <dl class="row">
                    <dt class="tit">
                        <label ></label>
                    </dt>
                    <dd class="opt">
                        <input style="width:100px ! important" type="text" name="start[]" class="input-txt" placeholder="起始公里">---
                        <input style="width:100px ! important" type="text" name="end[]" class="input-txt" placeholder="结束公里">KM
                        <input style="width:100px ! important" type="text" name="val[]" class="input-txt" placeholder="每公里单价">元
                    </dd>
                </dl>
            </div>
            <dl class="row">
                <dt class="tit">
                    <label ><em></em>城市首字母</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="first_name" class="input-txt" style="text-transform: uppercase"> <span>  *只能输入一个字母</span>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label ><em></em>每分钟(元)</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="minute" class="input-txt">
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label ><em></em>平台手续费(%)</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="plate_fee" class="input-txt" placeholder="不要加%,直接输入费率">
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label ><em></em>司机恶意退单罚款(元)</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="order_punish" class="input-txt" placeholder="司机恶意退单罚款">
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label ><em></em>乘客投诉罚款(元)</label>
                </dt>
                <dd class="opt">
                    <input type="text" name="user_punish" class="input-txt" placeholder="乘客投诉罚款">
                </dd>
            </dl>
            <div class="bot">
                <a href="JavaScript:void(0);" onclick="adsubmit();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    // 判断输入框是否为空
    function adsubmit() {
        // if($('input[name=user_name]').val() == ''){
        //     layer.msg('用户名不能为空！', {icon: 2,time: 1000});   //alert('少年，用户名不能为空！');
        //     return false;
        // }
        // // if($('input[name=email]').val() == ''){
        // //     layer.msg('邮箱不能为空！', {icon: 2,time: 1000});//alert('少年，邮箱不能为空！');
        // //     return false;
        // // }
        // if($('input[name=password]').val() == ''){
        //     layer.msg('密码不能为空！', {icon: 2,time: 1000});//alert('少年，密码不能为空！');
        //     return false;
        // }
        $('#adminHandle').submit();
    }


    $(document).ready(function () {
        $(document).on('click', '#adds', function () {
            var str = ' <dl class="row">                    <dt class="tit">                     <label ></label>                    </dt>                    <dd class="opt">                        <input type="text" name="start[]" class="input-txt"  placeholder="起始公里" style="width:100px ! important" >---<input style="width:100px ! important" type="text" name="end[]" class="input-txt"  placeholder="结束公里">KM   <input style="width:100px ! important" type="text" name="val[]" class="input-txt"  placeholder="每公里单价">元                    </dd>                </dl>';
            $("#cons").append(str);
        });
        get_province();
    });

    /**
     * 获取省份
     */
    function get_province() {
        var url = "{:url('/admin/system/getRegion','level=2&parent_id=1')}";
        ajax(url,'选择省份',$('#province'));
    }

    /**
     * 获取城市
     * @param t  省份select对象
     */

    function get_city(t) {
        var parent_id = $(t).val();
        if (!parent_id > 0) {
            return;
        }
        $('#district').html("<option value=''>选择区域</option>");
        var url = "{:url('/admin/system/getRegion','level=3&parent_id=')}" + parent_id;
        ajax(url,'选择城市',$('#city'));
    }

    /**
     * 获取地区
     * @param t  城市select对象
     */
    function get_area(t) {
        var parent_id = $(t).val(),district =$('#district') ;
        if (!parent_id > 0) {
            return;
        }
        district.html("<option value=''>选择区域</option>");
        var url = "{:url('/admin/system/getRegion','level=4&parent_id=')}" + parent_id;
        ajax(url,'选择区域',district);
    }

    function ajax(url,op,obj) {
        $.ajax({
            type: "GET",
            url: url,
            error: function (request) {
                alert("服务器繁忙, 请联系管理员!");
                return;
            },
            success: function (v) {
                switch (v['status']){
                    case 1:
                        var s = "<option value=''>"+op+'</option>' + v['html'];
                        obj.html(s);
                        break;
                    default:
                        alert(v['msg']);
                        break;
                }
            }
        });
    }
</script>
</body>
</html>